package net.jsoft.platform.security.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import net.jsoft.platform.security.entity.user.SysRole;
import net.jsoft.platform.security.entity.user.SysUser;
import net.jsoft.pms.entity.dept.Dept;

public interface UserRepository extends JpaRepository<SysUser, Long>
{

    SysUser findByName(String name);

    @Query("from SysUser u where u.name=:name")
    SysUser findUser(@Param("name") String name);

    @Query("from SysUser u where u.fullName=:name")
    SysUser findUserByFullName(@Param("name") String name);

    @Query("from SysRole  ")
    List<SysRole> findAllRole();

    @Query("from Dept where id = :id ")
    Dept findDept(@Param("id") long id);

    @Query("from SysUser u where u.dept = :dept")
    List<SysUser> findByDept(@Param("dept") Dept dept);

    @Query("from SysUser u order by dept  ")
    List<SysUser> findAllOrderByDept();

}